<?php
require_once ("../db/connectdatabase.php");

function getPurposeLoan() {
	$con = new ConnectDB();
	
	$tbl = "purposeloan";
	$fn = array('idpurpose', 'namepurp');
	$condetion = array('isuse' => true);
	return $con -> getvalueorderby($tbl, $fn, $condetion, 'datecreate');
}


function insertProduct($id, $name) {
	$con = new ConnectDB();
	
	$tbl = "purposeloan";
	$fn = array('idpurpose' => $id, 'namepurp' => $name, 'datecreate' => time());
	return $con -> insert($tbl, $fn);
}

function updateProduct($id, $name) {
	$con = new ConnectDB();
	
	$tbl = "purposeloan";
	$fn = array('namepurp' => $name, 'datecreate' => time());
	$condition = array('idpurpose' => $id);
	return $con -> update($tbl, $fn, $condition);
}

function deleteProduct($id) {
	$con = new ConnectDB();
	
	$tbl = "purposeloan";
	$fn = array('isuse' => false);
	$condition = array('idpurpose' => $id);
	return $con -> update($tbl, $fn, $condition);
}

?>